<?php
defined('_JEXEC') or die('Direct Access to this location is not allowed.');
 
class ModPropertiesScrollerHelper
{
	
    /**
     * Returns a list of random products
    */	
    public function getProperties($count)
    {
        // get a reference to the database
        $db = &JFactory::getDBO();
 
        // get a list of products randomly ordered products 
        $query = 'SELECT * FROM `#__properties_products` AS p WHERE p.published = 1 ORDER BY listdate DESC LIMIT ' . $count  . ' ';
 
        $db->setQuery($query);
        $items = ($items = $db->loadObjectList())?$items:array();
 
        return $items;
    } //end getItems
    
	/*
	function NameCategory()
	{
		$db 	=& JFactory::getDBO();
		$query = 'SELECT * FROM #__properties_category WHERE published = 1 ORDER BY id';
		$db->setQuery($query);
		$Categories = $db->loadObjectList();

		foreach ($Categories as $row) :
		$Category[$row->id] = $row->name;
		endforeach;

		return $Category;
	}

	function NameType()
	{
		$db 	=& JFactory::getDBO();
		$query = 'SELECT * FROM #__properties_type WHERE published = 1 ORDER BY name';
		$db->setQuery($query);
		$Types = $db->loadObjectList();

		foreach ($Types as $row) :
		$Type[$row->id] = $row->name;
		endforeach;

			
		return $Type;
	}

	function NameCountry()
	{
		$db 	=& JFactory::getDBO();
		$query = 'SELECT * FROM #__properties_country WHERE published = 1 ORDER BY name';
		$db->setQuery($query);
		$Countries = $db->loadObjectList();
			
		foreach ($Countries as $row) :
		$Country[$row->id] = $row->name;
		endforeach;

		return $Country;
	}
	function NameState()
	{
		$db 	=& JFactory::getDBO();
		$query = 'SELECT * FROM #__properties_state WHERE published = 1 ORDER BY name';
		$db->setQuery($query);
		$States = $db->loadObjectList();

		foreach ($States as $row) :
		$State[$row->id] = $row->name;
		endforeach;

		return $State;
	}
	function NameLocality()
	{
		$db 	=& JFactory::getDBO();
		$query = 'SELECT * FROM #__properties_locality WHERE published = 1 ORDER BY name';
		$db->setQuery($query);
		$Localities = $db->loadObjectList();

		foreach ($Localities as $row) :
		$Locality[$row->id] = $row->name;
		endforeach;

		return $Locality;
	}
	*/
} //end SimplestForumLatestPostsHelper
